home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Disc to the Future 2
/
Disc to the Future Part II Programmer's Reference (Wayzata Technology)(6013)(1992).bin
/
MAC
/
THINKC
/
3_0
/
CUTILSLI
/
UTILITYL
/
ATOI.C
next >
Wrap
Text File
|
1987-11-10
|
1KB
|
47 lines
/**********************************************
* Filename: atoi.c
* Purpose: Atoi Function
* Authors: Robert E. Neville
* Date: November 10, 1987
* Functions: atoi().
* Version: 1.0
* Copyright: ⌐ 1987 Hummingbird Graphics
***********************************************/
#include <MacTypes.h>
#include <Strings.h>
#include <Pascal.h>
/* Macro */
#define isspace(c) (c== ' ' || c == '\t')
#define ZERO 48
/*************************************************
* Function: atoi( string )
* Purpose: Convert ASCII string to an Integer
* Passed: string - Register Char *
* Returned: answer - Long converted to int
**************************************************/
atoi(string)
register char *string;
{
register long answer = 0L;
Boolean negative = FALSE;
while ( isspace(*string) )
string++;
if ( *string == '-' )
negative = TRUE;
while ( *string )
{
answer = (answer * 10) + (*string - ZERO);
string++;
}
if ( negative )
answer = 0 - answer;
return (int)answer;
}
/********** End of File **********/